import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommissionVO, CommissionForm, CommissionQuery } from '@/api/company/commission/types';

/**
 * 查询佣金信息列表
 * @param query
 * @returns {*}
 */

export const listCommission = (query?: CommissionQuery): AxiosPromise<CommissionVO[]> => {
  return request({
    url: '/system/commission/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询佣金信息详细
 * @param commissionId
 */
export const getCommission = (commissionId: string | number): AxiosPromise<CommissionVO> => {
  return request({
    url: '/system/commission/' + commissionId,
    method: 'get'
  });
};

/**
 * 新增佣金信息
 * @param data
 */
export const addCommission = (data: CommissionForm) => {
  return request({
    url: '/system/commission',
    method: 'post',
    data: data
  });
};

/**
 * 修改佣金信息
 * @param data
 */
export const updateCommission = (data: CommissionForm) => {
  return request({
    url: '/system/commission',
    method: 'put',
    data: data
  });
};

/**
 * 删除佣金信息
 * @param commissionId
 */
export const delCommission = (commissionId: string | number | Array<string | number>) => {
  return request({
    url: '/system/commission/' + commissionId,
    method: 'delete'
  });
};
